﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：YS_ZW_NEIBUZZXX实体层次
//********************************************************************************//

#region Entity

using System;
using System.Data;
using Entity;
using Oracle.DataAccess.Client;
using Platform.Configuration;
using Platform.Data;

namespace Entity
{
    [Serializable]
    public class YS_ZW_NEIBUZZXX
    {
        private double? m_db_n_jine;

        private decimal? m_dec_i_chulir;

        private decimal? m_dec_i_feiybh_in;

        private decimal? m_dec_i_feiybh_out;

        private decimal? m_dec_i_jlzt;

        private decimal? m_dec_i_zwym;

        private decimal m_dec_id;

        private DateTime? m_DT_d_chulirq;

        private string m_str_s_by1;

        private string m_str_s_by2;

        /// <summary>
        ///     id
        /// </summary>
        public decimal ID
        {
            get { return m_dec_id; }
            set { m_dec_id = value; }
        }

        /// <summary>
        ///     处理日期
        /// </summary>
        public DateTime? D_CHULIRQ
        {
            get { return m_DT_d_chulirq; }
            set { m_DT_d_chulirq = value; }
        }

        /// <summary>
        ///     账务年月
        /// </summary>
        public decimal? I_ZWYM
        {
            get { return m_dec_i_zwym; }
            set { m_dec_i_zwym = value; }
        }

        /// <summary>
        ///     处理人
        /// </summary>
        public decimal? I_CHULIR
        {
            get { return m_dec_i_chulir; }
            set { m_dec_i_chulir = value; }
        }

        /// <summary>
        ///     转出费用编号
        /// </summary>
        public decimal? I_FEIYBH_OUT
        {
            get { return m_dec_i_feiybh_out; }
            set { m_dec_i_feiybh_out = value; }
        }

        /// <summary>
        ///     转入费用编号
        /// </summary>
        public decimal? I_FEIYBH_IN
        {
            get { return m_dec_i_feiybh_in; }
            set { m_dec_i_feiybh_in = value; }
        }

        /// <summary>
        ///     金额
        /// </summary>
        public double? N_JINE
        {
            get { return m_db_n_jine; }
            set { m_db_n_jine = value; }
        }

        /// <summary>
        ///     是否逻辑删除
        /// </summary>
        public decimal? I_JLZT
        {
            get { return m_dec_i_jlzt; }
            set { m_dec_i_jlzt = value; }
        }

        /// <summary>
        ///     备用1
        /// </summary>
        public string S_BY1
        {
            get { return m_str_s_by1; }
            set { m_str_s_by1 = value; }
        }

        /// <summary>
        ///     备用2
        /// </summary>
        public string S_BY2
        {
            get { return m_str_s_by2; }
            set { m_str_s_by2 = value; }
        }
    }
}

#endregion

#region EntityProcess

namespace BLL.Access
{
    //using System.Data.OracleClient;

    public class YS_ZW_NEIBUZZXXProcess
    {
        #region Field

        protected string conn;

        #endregion

        #region Construction

        public YS_ZW_NEIBUZZXXProcess()
        {
            conn = ConfigHelper.PlatformConnString;
        }

        #endregion

        #region public

        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX实体添加或者修改YS_ZW_NEIBUZZXX信息
        /// </summary>
        public bool InsertOrUpdate(YS_ZW_NEIBUZZXX YS_ZW_NEIBUZZXX, OracleTransaction Transaction)
        {
            if (YS_ZW_NEIBUZZXX.ID == 0)
                InsertYS_ZW_NEIBUZZXX(YS_ZW_NEIBUZZXX, Transaction);
            else
                UpdateYS_ZW_NEIBUZZXX(YS_ZW_NEIBUZZXX, Transaction);
            return YS_ZW_NEIBUZZXX.ID == 0 ? false : true;
        }

        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX实体添加或修改YS_ZW_NEIBUZZXX信息
        /// </summary>
        public bool InsertOrUpdate(YS_ZW_NEIBUZZXX YS_ZW_NEIBUZZXX)
        {
            return InsertOrUpdate(YS_ZW_NEIBUZZXX, null);
        }


        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX主键删除YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_ZW_NEIBUZZXX(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_DelYS_ZW_NEIBUZZXX";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX主键删除YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteYS_ZW_NEIBUZZXX(decimal ID)
        {
            return DeleteYS_ZW_NEIBUZZXX(ID, null);
        }

        /// <summary>
        ///     根据条件删除YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_ZW_NEIBUZZXXesDynamic(string WhereClause, OracleTransaction Transaction)
        {
            var spName = "CS_DelYS_ZW_NEIBUZZXXesDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据条件删除YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteYS_ZW_NEIBUZZXXesDynamic(string WhereClause)
        {
            return DeleteYS_ZW_NEIBUZZXXesDynamic(WhereClause, null);
        }

        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX主键选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public YS_ZW_NEIBUZZXX SelectYS_ZW_NEIBUZZXX(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_NEIBUZZXX";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                var YS_ZW_NEIBUZZXX = PopulateYS_ZW_NEIBUZZXX(rd);
                rd.Close();
                return YS_ZW_NEIBUZZXX;
            }
            return null;
        }

        /// <summary>
        ///     根据YS_ZW_NEIBUZZXX主键选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public YS_ZW_NEIBUZZXX SelectYS_ZW_NEIBUZZXX(decimal ID)
        {
            return SelectYS_ZW_NEIBUZZXX(ID, null);
        }

        /// <summary>
        ///     选择所有YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesAll(OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_NEIBUZZXXesAll";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }

        /// <summary>
        ///     选择所有YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <returns>所有YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesAll()
        {
            return SelectYS_ZW_NEIBUZZXXesAll(null);
        }

        /// <summary>
        ///     根据条件选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesDynamic(string WhereClause, string OrderByExpression,
            OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_NEIBUZZXXesDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectYS_ZW_NEIBUZZXXesDynamic(WhereClause, OrderByExpression, null);
        }


        /// <summary>
        ///     根据条件选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize, OracleTransaction Transaction)
        {
            var spName = "CS_SelYS_ZW_NEIBUZZXXesDynPaged";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择YS_ZW_NEIBUZZXX信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>YS_ZW_NEIBUZZXX信息</returns>
        public DataTable SelectYS_ZW_NEIBUZZXXesDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize)
        {
            return SelectYS_ZW_NEIBUZZXXesDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///     根据条件更新YS_ZW_NEIBUZZXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_ZW_NEIBUZZXXesDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            var result = 0;
            if (UpdateValue == "" || WhereClause == "")
                return 0;
            var spName = "CS_UpdYS_ZW_NEIBUZZXXDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///     根据条件更新YS_ZW_NEIBUZZXX字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateYS_ZW_NEIBUZZXXesDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateYS_ZW_NEIBUZZXXesDynamic(UpdateValue, WhereClause, null);
        }

        #endregion

        #region Private

        private int InsertYS_ZW_NEIBUZZXX(YS_ZW_NEIBUZZXX YS_ZW_NEIBUZZXX, OracleTransaction Transaction)
        {
            var spName = "CS_InsYS_ZW_NEIBUZZXX";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_ZW_NEIBUZZXX.D_CHULIRQ;
            storedParams[1].Value = YS_ZW_NEIBUZZXX.I_ZWYM;
            storedParams[2].Value = YS_ZW_NEIBUZZXX.I_CHULIR;
            storedParams[3].Value = YS_ZW_NEIBUZZXX.I_FEIYBH_OUT;
            storedParams[4].Value = YS_ZW_NEIBUZZXX.I_FEIYBH_IN;
            storedParams[5].Value = YS_ZW_NEIBUZZXX.N_JINE;
            storedParams[6].Value = YS_ZW_NEIBUZZXX.I_JLZT;
            storedParams[7].Value = YS_ZW_NEIBUZZXX.S_BY1;
            storedParams[8].Value = YS_ZW_NEIBUZZXX.S_BY2;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            YS_ZW_NEIBUZZXX.ID = Convert.ToInt32(storedParams[9].Value);
            return result;
        }

        private bool UpdateYS_ZW_NEIBUZZXX(YS_ZW_NEIBUZZXX YS_ZW_NEIBUZZXX, OracleTransaction Transaction)
        {
            var spName = "CS_UpdYS_ZW_NEIBUZZXX";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = YS_ZW_NEIBUZZXX.D_CHULIRQ;
            storedParams[1].Value = YS_ZW_NEIBUZZXX.I_ZWYM;
            storedParams[2].Value = YS_ZW_NEIBUZZXX.I_CHULIR;
            storedParams[3].Value = YS_ZW_NEIBUZZXX.I_FEIYBH_OUT;
            storedParams[4].Value = YS_ZW_NEIBUZZXX.I_FEIYBH_IN;
            storedParams[5].Value = YS_ZW_NEIBUZZXX.N_JINE;
            storedParams[6].Value = YS_ZW_NEIBUZZXX.I_JLZT;
            storedParams[7].Value = YS_ZW_NEIBUZZXX.S_BY1;
            storedParams[8].Value = YS_ZW_NEIBUZZXX.S_BY2;
            storedParams[9].Value = YS_ZW_NEIBUZZXX.ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private YS_ZW_NEIBUZZXX PopulateYS_ZW_NEIBUZZXX(IDataReader dr)
        {
            var YS_ZW_NEIBUZZXX = new YS_ZW_NEIBUZZXX();
            YS_ZW_NEIBUZZXX.ID = dr["ID"] == DBNull.Value ? 0 : (decimal) dr["ID"];
            YS_ZW_NEIBUZZXX.D_CHULIRQ = dr["D_CHULIRQ"] == DBNull.Value ? null : (DateTime?) dr["D_CHULIRQ"];
            YS_ZW_NEIBUZZXX.I_ZWYM = dr["I_ZWYM"] == DBNull.Value ? null : (decimal?) dr["I_ZWYM"];
            YS_ZW_NEIBUZZXX.I_CHULIR = dr["I_CHULIR"] == DBNull.Value ? null : (decimal?) dr["I_CHULIR"];
            YS_ZW_NEIBUZZXX.I_FEIYBH_OUT = dr["I_FEIYBH_OUT"] == DBNull.Value ? null : (decimal?) dr["I_FEIYBH_OUT"];
            YS_ZW_NEIBUZZXX.I_FEIYBH_IN = dr["I_FEIYBH_IN"] == DBNull.Value ? null : (decimal?) dr["I_FEIYBH_IN"];
            YS_ZW_NEIBUZZXX.N_JINE = dr["N_JINE"] == DBNull.Value ? null : (double?) dr["N_JINE"];
            YS_ZW_NEIBUZZXX.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?) dr["I_JLZT"];
            YS_ZW_NEIBUZZXX.S_BY1 = dr["S_BY1"] == DBNull.Value ? null : (string) dr["S_BY1"];
            YS_ZW_NEIBUZZXX.S_BY2 = dr["S_BY2"] == DBNull.Value ? null : (string) dr["S_BY2"];
            return YS_ZW_NEIBUZZXX;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (var i = 0; i < dt.Rows.Count; i++)
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
        }

        #endregion
    }
}

#endregion